<template>
    <el-dialog
       right
       title="提示"
       :visible.sync="dialogVisible"
       width="30%"
       :before-close="handleClose">
       <span>
          <i v-if="hType === 1" class="el-icon-info" style="font-size:25px;margin-right:10px;vertical-align:middle;"></i>
          <i v-else class="el-icon-warning" style="font-size:25px;margin-right:10px;vertical-align:middle;color:#e6a23c;"></i>
       </span>
       <span v-if="hType === 1">此操作将该题目加入精选, 是否继续?</span>
       <span v-else-if="hType === 0">此操作将永久删除题目, 是否继续?</span>
       <div slot="footer" class="dialog-footer">
         <el-button @click="dialogVisible = false">取 消</el-button>
         <el-button @click="choiceAdd" type="primary">确 定</el-button>
       </div>
    </el-dialog>
</template>
<script>
import { choiceAdd } from '@/api/hmmm/questions'

export default {
  props: {
    isShowDialog: {
      type: Boolean,
      required: true
    },
    dialogID: {
      type: [Number, String],
      required: true
    },
    hType: {
      type: [Number, String],
      required: true
    }
    // hChoiceType: {
    //   type: Number,
    //   required: true
    // }
  },
  data () {
    return {
      dialogVisible: false // 对话框显示隐藏
    }
  },
  created () {},
  methods: {
    getChoice () {
      this.dialogVisible = this.isShowDialog
      console.log(this.dialogID, this.hType)
      // await choiceAdd({ id: this.dialogID, choiceState: 1 })
    },
    async choiceAdd () {
      this.dialogVisible = false
      if (this.hType) {
        await choiceAdd({ id: this.dialogID, choiceState: 1 })
        this.$message.success('添加精选成功')
        this.$emit('updateData')
      } else if (this.hType === 0) {
        this.$emit('remove')
      }
    },
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {})
    }
  }
}
</script>
